package cm.tl.pms.common.type;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @Author emanjusaka
 * @Date 2024/11/28 17:19
 * @Version 1.0
 */
@Data
@AllArgsConstructor
public class GeomPoint {
    /**
     * 经度
     */
    private double lat;
    /**
     * 纬度
     */
    private double lng;

    public GeomPoint() {
    }

    public GeomPoint parse(String pointString) {
        String[] latLng = pointString.toLowerCase().replaceAll("point\\(", "").replaceAll("\\)", "")
                .split(" ");
        setLat(Double.parseDouble(latLng[0]));
        setLng(Double.parseDouble(latLng[1]));
        return this;
    }

    @Override
    public String toString() {
        return "point(" + lng + " " + lat + ")";
    }
}